package com.base.monitor.admin.controller.biz.collect;

import com.base.monitor.framework.annotation.RefuseResponseResult;
import com.base.monitor.framework.annotation.ResponseResult;
import com.base.monitor.framework.result.PageResult;
import com.base.monitor.model.model.biz.collect.criteria.ChannelCriteria;
import com.base.monitor.model.model.biz.collect.dto.HandleChannelDto;
import com.base.monitor.module.biz.context.ClientContext;
import com.base.monitor.module.biz.service.collect.ChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/col/channel")
@ResponseResult
public class ChannelController {

    @Autowired
    private ChannelService channelService;

    /**
     * 分页条件查询信道信息
     * @param channelCriteria 查询条件
     * @return
     */
    @GetMapping
    @RefuseResponseResult
    public PageResult<ClientContext.ChannelInfo> page(ChannelCriteria channelCriteria) {
        return channelService.page(channelCriteria);
    }

    /**
     * 强制下线指定信道
     * @param handleChannelDto 该信道的连接信息
     */
    @PostMapping("/kick")
    public void kick(@RequestBody HandleChannelDto handleChannelDto) {
        channelService.kick(handleChannelDto);
    }

    /**
     * 将指定信道加入黑名单
     * @param handleChannelDto 该信道的连接信息
     */
    @PostMapping("/blacklist")
    public void blacklist(@RequestBody HandleChannelDto handleChannelDto) {
        channelService.blacklist(handleChannelDto);
    }

    /**
     * 将指定信道从黑名单中移除
     * @param handleChannelDto 该信道的连接信息
     */
    @PostMapping("/cancel")
    public void cancel(@RequestBody HandleChannelDto handleChannelDto) {
        channelService.cancel(handleChannelDto);
    }
}
